#include<iostream>

class Complex
{
private:
    int real; //实部
    int vir; //虚部

public:
    Complex():real(0),vir(0){}
    Complex(int real, int vir):real(real),vir(vir){}
    // void show()
    // {
    //     std::cout<<real<<"+"<<vir<<"i"<<std::endl;
    // }

    Complex operator+(const Complex& c)
    {
        Complex result;
        result.real= this->real+c.real;
        result.vir=this->vir+c.vir;
        return result;
    }

    Complex operator-(const Complex& c)
    {
        Complex result;
        result.real= this->real-c.real;
        result.vir=this->vir-c.vir;
        return result;
    }

    //++a  给的时左值
    //占位参数
    Complex& operator++()
    {
        real++;
        vir++;
        return *this;   //在函数内部返回自己
    }

    //a++  给的是右值
    Complex operator++(int)
    {
        Complex result = *this;  //调用拷贝构造函数
        real++;
        vir++;
        return result;
    }

    friend std::ostream& operator<<(std::ostream& os, const Complex& c);
    friend std::istream &operator>>(std::istream &is, Complex &c);
};

//不能作为成员函数重载:写法和一般习惯不同
//所以要做全局重载
//定义友元函数为了访问类的私有变量
    std::ostream& operator<<(std::ostream& os, const Complex& c)
    {
        std::cout<<c.real<<"+"<<c.vir<<"i";
        return os;
    }

    std::istream &operator>>(std::istream &is, Complex &c)
    {
        std::cin>>c.real>>c.vir;
        return is;
    }

int main()
{
    Complex c(1,2);
    Complex c1(2,3);
    // Complex c1= c++;

    // c.show();
    // c1.show();

    // Complex c2= c+c1;  //相当于c.operator+(c1) 简化了表达形式，本质不变
    // Complex c2=c1-c;
    // c2.show();

    std::cin>>c;
    std::cout<<c<<std::endl;

    return 0;
}